This tutorial will walk through how to deply the Rock Paper Scissors Neural Network Model trained in the previous tutorial to a Raspi Pico. This is achieved by exporting a C++ library and using it to overwrite a framework project with your own model before compiling and uploading to a Raspi Pico using the built in USB file system drag and drop bootloader.

Prerequisites

The Virtual Breadboard SDK for RaspiPi contains projects and frameworks that can be used to program a RaspPi Pico to run Virtual Breadboard application via the EDGEY interface.

  1. Open a Command Line with Raspi Make Tools eg The Visual Studio Developer Command Prompt setup in the prerequisit tutorial or your prefered linux toolchain
  2. Change to the Raspi SDK Directory. eg c:\RP2040
  3. Install the vbb-raspi-pico sdk using git

    git clone https://github.com/virtualbreadboard/vbb-raspi-pico.git

The Virtual Breadboard for RaspiPi SDK has an example which can used to capture the gesture information from VBB via the EDGEY interface already setup for classification

Change directory to the edge-rps example

cd vbb-raspi-pico\tinyML\edge-rps

The project contents should be

Example directory

The ei_rp2040_firmware.uf2 is the end result of the compile process and you can use this file as a short cut. The rest of this tutorial explains how to build it yourself.

The directories edge-impulse-sdk, model-paramters, tflite are exported from your edge impulse deployment process. These folders and their contents we will replace with our own model files in the next step.

A C++ Library model can be deployed as source code to be compiled into your own project. The deployment model contains all the files you need including the tensforflow neural network evaluation engine and the weightings for your trained model ready to go.

To deploy your model:

  1. From the Deployment Tab
  2. Select C++ Library

  1. Scroll down and Click Build

  1. This will generated and download a your-project-version.zip file
  2. Save the zip file to the edge-rps project folder

The idea is to replace the existing edge-impulse-sdk, model-paramters, tflite folders in the project with the folders from the deployed model.

One way to do this is:

  1. Unzip the exported model into the project folder
  2. Navigate to the Model directory
  3. Select and copy the edge-impulse-sdk, model-paramters, tflite folders
  4. Navigate to the Project directory
  5. Paste the new model folders over the old model folders

Extract

Copy Overlay

Paste Overlay

The next step is to use the CMMake system to generate build files for the project preparing it to compile. To do this we create a build directory and instuct CMake to scan the project files for CMake directives to create build files for all the projects in the SDK including edge-rps project

  1. Open the command line window again
  2. Navigate back to tinyML directory
    >cd ..
  3. Create a build directory
    >mkdir build
  4. Navigate to the build directory
    >cd build
  5. Execute the cmake
    >cmake -G "NMake Makefiles" ..

Having created the make files we are not ready to compile the project to create the hex and .uf2 bootloable file.

  1. Change directory to the build
    >cd build
  2. Execute the nmake command
    >nmake
  3. The ei_rp2040_firmware.u2f output file is /build/tinyML/edge-rps directory

Programming the Raspberry Pi Pico can be achieved by dragging and dropping the ei_rp2040_firmware.u2f to the bootloader file system of the Raspberry Pico. When the Pico is connected to the USB port with the reset button pressed the Pico will mount as a USB file system.

To program:

  1. Make sure the Pico is disconnected from the USB
  2. Press and HOLD down the Reset button
  3. Connect the Pico to the USB port
  4. Release the Reset button after the USB is connected
  5. The USB Filesystem should mount and popup as a Windows Explorer folder
  6. Drag and Drop the ei_rp2040_firmware.u2f from the edge-rps folder to the Pico Boot Folder

Congratulations you have successfully programmed your Raspberry Pi Pico with your own model. The next step is to test it.

Upcoming Tutorials: